package org.huntaway.material.cleaner;

import java.util.ArrayList;
import java.util.Collection;

import org.huntaway.material.cleaner.arguments.model.ArgumentsVisitor;
import org.huntaway.material.cleaner.arguments.model.Visitable;
import org.huntaway.material.cleaner.arguments.model.imp.ArgsConcreteVisitor;
import org.huntaway.material.cleaner.arguments.model.imp.FirstArguments;
import org.huntaway.material.cleaner.arguments.model.imp.ThreeArguments;
import org.huntaway.material.cleaner.arguments.model.imp.TwoArguments;
import org.huntaway.material.cleaner.operate.model.imp.AntOperateImp;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class Material {
	private final static Logger logger = LoggerFactory.getLogger(Material.class);

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Material mate = new Material();
		String[] arg = { "oi", "tomcat6" };
		mate.treate(arg);
	}

	private void treate(String[] args) {
		showArgs(args);
		ArgumentsVisitor visitor = new ArgsConcreteVisitor(new AntOperateImp());
		Collection<Visitable> list = new ArrayList<Visitable>();
		if (args.length > 0) {
			list.add(new FirstArguments(args[0]));
		}
		if (args.length > 1) {
			list.add(new TwoArguments(args[1]));
		}
		if (args.length > 2) {
			list.add(new ThreeArguments(args[2]));
		}
		visitor.visitCollection(list);
	}

	private void showArgs(String[] args) {
		String resStr = "";
		for (int i = 0; i < args.length; i++) {
			resStr = resStr.equals("") ? args[i] : resStr + " " + args[i];
		}
		logger.info(resStr);
	}
}
